/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.yogi.webframework.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Yogi
 */
@Entity
@Table(name = "t_order_detail")
@NamedQueries({
    @NamedQuery(name = "OrdoDetail.findAll", query = "SELECT o FROM OrdoDetail o"),
    @NamedQuery(name = "OrdoDetail.findByTOrderId", query = "SELECT o FROM OrdoDetail o WHERE o.ordoDetailPK.tOrderId = :tOrderId"),
    @NamedQuery(name = "OrdoDetail.findByTMaterialsId", query = "SELECT o FROM OrdoDetail o WHERE o.ordoDetailPK.tMaterialsId = :tMaterialsId"),
    @NamedQuery(name = "OrdoDetail.findByTProductPartNum", query = "SELECT o FROM OrdoDetail o WHERE o.ordoDetailPK.tProductPartNum = :tProductPartNum"),
    @NamedQuery(name = "OrdoDetail.findByPrize", query = "SELECT o FROM OrdoDetail o WHERE o.prize = :prize")})
public class OrdoDetail implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected OrdoDetailPK ordoDetailPK;
    @Column(name = "PRIZE")
    private Float prize;
    @JoinColumn(name = "T_MATERIALS_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Materials materials;
    @JoinColumn(name = "T_PRODUCT_PART_NUM", referencedColumnName = "NUM", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private ProductPart productPart;
    @JoinColumn(name = "T_ORDER_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Ordo ordo;

    public OrdoDetail() {
    }

    public OrdoDetail(OrdoDetailPK ordoDetailPK) {
        this.ordoDetailPK = ordoDetailPK;
    }

    public OrdoDetail(int tOrderId, int tMaterialsId, int tProductPartNum) {
        this.ordoDetailPK = new OrdoDetailPK(tOrderId, tMaterialsId, tProductPartNum);
    }

    public OrdoDetailPK getOrdoDetailPK() {
        return ordoDetailPK;
    }

    public void setOrdoDetailPK(OrdoDetailPK ordoDetailPK) {
        this.ordoDetailPK = ordoDetailPK;
    }

    public Float getPrize() {
        return prize;
    }

    public void setPrize(Float prize) {
        this.prize = prize;
    }

    public Materials getMaterials() {
        return materials;
    }

    public void setMaterials(Materials materials) {
        this.materials = materials;
    }

    public ProductPart getProductPart() {
        return productPart;
    }

    public void setProductPart(ProductPart productPart) {
        this.productPart = productPart;
    }

    public Ordo getOrdo() {
        return ordo;
    }

    public void setOrdo(Ordo ordo) {
        this.ordo = ordo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ordoDetailPK != null ? ordoDetailPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdoDetail)) {
            return false;
        }
        OrdoDetail other = (OrdoDetail) object;
        if ((this.ordoDetailPK == null && other.ordoDetailPK != null) || (this.ordoDetailPK != null && !this.ordoDetailPK.equals(other.ordoDetailPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.yogi.webframework.model.OrdoDetail[ordoDetailPK=" + ordoDetailPK + "]";
    }

}
